#include "cbasewidget.h"
#include <QGraphicsDropShadowEffect>
#include <QPainter>
#include <QStyleOption>

CBaseWidget::CBaseWidget(QWidget *parent) : QWidget(parent)
{
}

CBaseWidget::~CBaseWidget()
{
}

void CBaseWidget::initWidget()
{
    !parent() ? setAttribute(Qt::WA_TranslucentBackground)
              : setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
}

void CBaseWidget::drawShadow(int radius)
{
    QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this);
    shadow->setOffset(0, 0);
    shadow->setColor(QColor("#444444"));
    shadow->setBlurRadius(radius);
    this->setGraphicsEffect(shadow);
}

void CBaseWidget::paintEvent(QPaintEvent *event)
{
    QStyleOption opt;
    opt.initFrom(this);
    QPainter p(this);
    style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
    QWidget::paintEvent(event);
}